import { Serialize, SerializeClass } from "../../core/serialize";
import { ECABase } from "./eca_base";

@SerializeClass("Event")
export class Event extends ECABase {
    hook(obj: any) {
        return new EvtHook(this);
    }
};

export class EvtHook {
    evt: Event = null;
    superCall: any = null;
    onTrigged: (evt:Event, ...args: any[]) => void = null;
    trigged(...args: any[]) {
        this.superCall && this.superCall.call(...args);
        this.onTrigged && this.onTrigged(this.evt, ...args);
    }
    constructor(evt: Event ){
        this.evt = evt;
    }
};